package mytest;

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import io.vertx.servicediscovery.ServiceDiscovery;
import io.vertx.servicediscovery.ServiceDiscoveryOptions;

/**
 * @Author Ldj
 * @Date 2017/10/31 16:41
 * @Description 数据处理
 */
public class Publishing extends AbstractVerticle {

    public static void main(String[] args) {
        ServiceDiscovery discovery = ServiceDiscovery.create(Vertx.vertx(), new ServiceDiscoveryOptions().setAnnounceAddress("service-announce").setName("my-name"));
        discovery.getRecord(r -> r.getName().equals("my-rest-api"), ar -> {
            if (ar.succeeded()) {
                if (ar.result() != null) {
                    // we have a record
                    System.out.println("------successed");
                } else {
                    System.out.println("------error");
                    // the lookup succeeded, but no matching service
                }
            } else {
                // lookup failed
            }
        });
    }

}
